package main

import (
	"os"
	"fmt"
	"go-glue.googlecode.com/hg/rlglue"
)

func main() {
	var err os.Error
	defer func() {
		if err != nil {
			panic(err)
		}
	}()
	gt := &GlueTester{"test_message", 0, 0}
	ex := new(rlglue.Experiment)
	if err = ex.AutoConnect(); err != nil {
		return
	}
	if _, err = ex.Init(); err != nil {
		return
	}
	var reply string
	reply, err = ex.EnvironmentMessage("")
	gt.check("empty" != reply)
	reply, err = ex.EnvironmentMessage("")
	gt.check("empty" != reply)
	reply, err = ex.AgentMessage("")
	gt.check("empty" != reply)
	reply, err = ex.AgentMessage("")
	gt.check("empty" != reply)
	reply, err = ex.EnvironmentMessage("empty")
	gt.check("" != reply)
	reply, err = ex.AgentMessage("empty")
	gt.check("" != reply)
	reply, err = ex.EnvironmentMessage("null")
	gt.check("" != reply)
	reply, err = ex.AgentMessage("null")
	gt.check("" != reply)
	reply, err = ex.EnvironmentMessage("1")
	gt.check("1" != reply)
	reply, err = ex.AgentMessage("1")
	gt.check("1" != reply)
	reply, err = ex.EnvironmentMessage("1000000000000000000000")
	gt.check("1000000000000000000000" != reply)
	reply, err = ex.AgentMessage("1000000000000000000000")
	gt.check("1000000000000000000000" != reply)
	reply, err = ex.EnvironmentMessage("21111111111111111111111111111111111111111111111111111111311111111111111111111111111111111111111111111111111111113")
	gt.check("21111111111111111111111111111111111111111111111111111111311111111111111111111111111111111111111111111111111111113" != reply)
	reply, err = ex.AgentMessage("45555555555555555555555555555555555555555555555555555555655555555555555555555555555555555555555555555555555555559")
	gt.check("45555555555555555555555555555555555555555555555555555555655555555555555555555555555555555555555555555555555555559" != reply)
	if err = ex.Cleanup(); err != nil {
		return
	}
	if err = ex.Close(); err != nil {
		return
	}
	fmt.Printf("%v\n", gt)
	os.Exit(gt.failCount)
}
